;var taotaoLink = {
    formatStr:function (s,param){

            for(var key in param) {
                s = s.replace(new RegExp("\\{\\{" + key + "\\}\\}", "g"), param[key]);
            }
            return s;
    },
    post0: function (url, paramData, succCallback, errCallback) {

        $.ajax({
            method: "POST",
            url: base_url + url,
            contentType: 'application/json',
            data: JSON.stringify(paramData),
            success: function (data, status) {
                if (data.code == "200") {
                    succCallback && succCallback(data, status)
                } else if (data.code == "403") {
                    layer.msg("登录失效,请重新登录");
                    setTimeout(function () {
                        window.location.href = base_url + "/login";
                    }, 500);
                } else {
                    errCallback && errCallback(data, status);
                }
            }
        });
    }, post: function (url, paramData, callBack0) {

        var callBack = {
            succMsg: null, succCallback: function (data, status) {
            }, errMsg: null, errCallback: function (data, status) {
            }
        };

        $.extend(callBack, callBack0);

        this.post0(url, paramData, function (data, status) {
            layer.msg(callBack.succMsg || "操作成功");
            setTimeout(function () {
                callBack.succCallback && callBack.succCallback(data, status)
            }, 500);
        }, function (data, status) {
            layer.open({
                title: "系统提示",
                btn: ["确定"],
                content: (data.msg || errMsg || "操作失败"),
                icon: '2',
                btn1: function (index, layero) {
                    // 按钮1的逻辑
                    callBack.errCallback && callBack.errCallback(data, status);
                    layer.close(index);
                },
                cancel: function () {
                    // 右上角关闭事件的逻辑
                    callBack.errCallback && callBack.errCallback(data, status);
                }
            });
        });


    }, get0: function (url, paramData, succCallback, errCallback) {
        $.ajax({
            method: "GET", url: base_url + url, data: paramData, success: function (data, status) {
                if (data.code == "200") {
                    succCallback && succCallback(data, status)
                } else if (data.code == "403") {
                    layer.msg("登录失效,请重新登录");
                    setTimeout(function () {
                        window.location.href = base_url + "/login";
                    }, 500);
                } else {
                    errCallback && errCallback(data, status);
                }
            }
        });
    }, get: function (url, paramData, callBack0) {
        var callBack = {
            succMsg: null, succCallback: function (data, status) {
            }, errMsg: null, errCallback: function (data, status) {
            }
        };

        $.extend(callBack, callBack0);


        this.get0(url, paramData, function (data, status) {
            layer.msg(callBack.succMsg || "操作成功");
            setTimeout(function () {
                callBack.succCallback && callBack.succCallback(data, status)
            }, 500);
        }, function (data, status) {
            layer.open({
                title: "系统提示",
                btn: ["确定"],
                content: (data.msg || callBack.errMsg || "操作失败"),
                icon: '2',
                btn1: function (index, layero) {
                    // 按钮1的逻辑
                    callBack.errCallback && callBack.errCallback(data, status);
                    layer.close(index);
                },
                cancel: function () {
                    // 右上角关闭事件的逻辑
                    callBack.errCallback && callBack.errCallback(data);
                }
            });
        });
    }, loading: function (content,timeount) {
        layer.closeAll('loading')
        index = layer.load(1, {
            content: content || '加载中',
            shade: [0.4, '#393D49'],
            time: timeount || 5000,  // 最长 等待5秒
            success: function (layero) {
                layero.css('padding-left', '30px');
                layero.find('.layui-layer-content').css({
                    'padding-top': '40px', 'width': '70px', 'color': 'white', 'background-position-x': '16px'
                });
            }
        });
        // layer.close(index);

        return index;

    },
    closeLoading: function (index) {
        layer.close(index);
    },
    closeAllLoading: function () {
        layer.closeAll('loading')
    },
    // 防止重复点击
    preventReClick :function (btn,timeount,clickFn){
        $(btn).prop("disabled",true);
        var index = taotaoLink.loading("请求中...",timeount)
        setTimeout(() => {
            $(btn).prop("disabled",false);
            //设置时间
        },  timeount|| 5000)

        clickFn && clickFn(btn,timeount)

    }


};


